package com.itheima.stream01;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class DemoArrayListNames {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("黄老邪");
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        //第一个队伍只要名字为3个字的成员姓名
        one.stream().filter(a->a.length()==3)
                .forEach(System.out::println);
        System.out.println("----------------------------");
        //第一个队伍筛选之后只要前3个人
        one.stream().limit(3)
                .forEach(System.out::println);
        System.out.println("-----------------------------");
        List<String> two = new ArrayList<>();
        two.add("张三丰");
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫声谷");
        //第二个队伍只要姓张的成员姓名
        two.stream().filter(s->s.contains("张"))
                .forEach(System.out::println);
        System.out.println("-----------------------------------");
        //第二个队伍筛选之后不要前2个人
        two.stream().skip(2).forEach(System.out::println);
        System.out.println("--------------------------------------");
        //将两个队伍合并为一个队伍
        Stream<List<String>> one1 = Stream.of(one);
        Stream<List<String>> two1 = Stream.of(two);
        Stream<List<String>> ot = Stream.concat(one1, two1);
        ot.forEach(System.out::println);
        System.out.println("-------------------------------------");


    }
}
